#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <stdlib.h>
#include <windows.h>

char *TraceFile = "C:\\temp\\trace.log";
int Trace = 1;

void TraceGame(const LPWSTR format, ...)
{
	if (!Trace) return;

	FILE *OutFile = stderr;

	if (TraceFile!=NULL)
	{
		if (fopen_s(&OutFile, TraceFile,"a")!=0) 
		{
			fprintf(stderr,"WARNING: Failed to open trace file '%s' for writing!\n",TraceFile);
			return;
		}
	}

	va_list ap;
	va_start(ap,format);
	vfwprintf(OutFile,format, ap);
	va_end(ap);

	fprintf(OutFile,"\n");

	if (TraceFile!=NULL) fclose(OutFile);
}
